#pragma once

class IEntity;
#include <vector>

class EntityManager
{
public:
	EntityManager() = default;
	~EntityManager() = default;
	size_t Size(int bucket){ return entities[bucket].size(); }
	const IEntity* Save(int bucket, int pos);
	//Entity storage
	void AddEntity(IEntity* entity, unsigned int bucket);
	void RemoveEntity(IEntity* entity, unsigned int bucket);
	void RemoveEntity(IEntity* entity);
	void RemoveAll(unsigned int bucket);
	void RemoveAll();

	//Entity Upkeep
	void UpdateAll(float elapsedTime);
	void RenderAll();

	void CheckCollisions(unsigned int bucket1, unsigned int bucket2);

private:
	EntityManager(const EntityManager&) = delete;
	EntityManager& operator= (const EntityManager&) = delete;

	typedef std::vector<IEntity*> EntityVector;
	typedef std::vector<EntityVector> EntityTable;

	EntityTable entities;
	bool iterating = false;
};

